package demo1;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] ch = in.next().toCharArray();
        int n = in.nextInt();

        int begin = 0, m = ch.length;
        int left = 0, right = 0;
        int t = 0, max = 0;
        while(right < m){
            if(ch[right] == 'C' || ch[right] == 'G'){
                t++;
            }
            while(right - left + 1 > n){
                if(ch[left] == 'C' || ch[left] == 'G'){
                    t--;
                }
                left++;
            }
            if(right - left + 1 == n){
                if(t > max){
                begin = left;
                max = t;
            }
            }
            right++;
        }
        for(int i = begin; i < begin + n; i++){
            System.out.print(ch[i]);
        }
    }
}